package cn.hdu.liang.ch1;

public class ThreadDemo4 {
    public static void main(String[] args) {
        Runnable r = () -> {
            String name = Thread.currentThread().getName();
            int count = 0;
            while(!Thread.interrupted()) {
                System.out.println(name + " : " + count++);
            }
        };

        Thread ta = new Thread(r);
        Thread tb = new Thread(r);
        ta.start();
        tb.start();

        try {
            Thread.sleep(20);
        } catch(InterruptedException e) {

        }

        ta.interrupt();
        tb.interrupt();
    }
}
